// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

var ClickManager = require('ClickManager')
var CreatorHelper = require('CreatorHelper')

cc.Class({
    extends: cc.Component,

    properties: {
        id: 0,
        username: cc.Label,
        headimg: cc.Sprite,
        rid: cc.Label,
        rname: cc.Label,
        listNode: cc.Node
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        // 点击节点
        ClickManager.onClick(this.listNode, this, () => {
            ClickManager.ccSetCache('__RID__', this.id)
            let canvas = cc.find('Canvas').getComponent('Union')
            canvas.removeAllTableAndDraw()
        })
    },

    start () {

    },

    // 初始化节点
    init (data) {
        this.id = data.id
        this.username.string = data.username
        CreatorHelper.changeSpriteFrame(this.headimg, data.headimg)
        this.rid.string = data.rid
        this.rname.string = data.rname
    }

    // update (dt) {},
});
